package tianrun.ziguan.api.calculate.config.config.excel;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.converters.ReadConverterContext;
import org.apache.commons.lang3.time.DateUtils;
import tianrun.ziguan.api.calculate.config.utils.DateUtil;

public class TimeConverter implements Converter<Long> {
    private static String[] parsePatterns = {
             "yyyy-MM-dd HH:mm:ss","yyyy/MM/dd HH:mm:ss", "yyyy-MM-dd HH:mm:ss.SSS","yyyy/MM/dd HH:mm:ss.SSS"};
    @Override
    public Long convertToJavaData(ReadConverterContext<?> context) throws Exception {
        return DateUtils.parseDate(context.getReadCellData().getStringValue(),parsePatterns).getTime();
    }
}
